﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BranchOfSansar.Sansar.Register;


namespace BranchOfSansar.Register.Authentication
{
    public partial class frmChooseRole : Form
    {
        public BranchOfSansar.Sansar.Enquiry.ComboItem SelectedRole { get; set; }
        public frmChooseRole()
        {
            InitializeComponent();
        }

        private void cmbRole_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.SelectedRole = (BranchOfSansar.Sansar.Enquiry.ComboItem)cmbRole.SelectedItem;
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void frmChooseRole_Load(object sender, EventArgs e)
        {
            using (RegisterClient reg = new RegisterClient(Globals.Token))
            {
                cmbRole.Properties.Items.AddRange(reg.RoleList().Select(s=>new BranchOfSansar.Sansar.Enquiry.ComboItem() { Display=s.Name, IntValue=s.RoleId }).ToList());
            }
        }
    }
}
